package com.cookbook.service.impl;

import com.cookbook.database.data.CookbookMapper;
import com.cookbook.database.model.Cookbook;
import com.cookbook.service.CookbookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by 胡玉斌 on 2017/7/3.
 */
@Service
public class CookbookServiceImpl implements CookbookService{

    @Autowired
    CookbookMapper cookbookMapper;

    @Override
    public List<Cookbook> select(int page, int limit) throws Exception {
        int offset = page * limit;
        return cookbookMapper.selectWithOffset(offset, limit);
    }

    @Override
    public List<Cookbook> search(String search_cookbook) throws Exception {
        return cookbookMapper.search(search_cookbook);
    }

    @Override
    public void insert(Cookbook cookbook) throws Exception {
        cookbookMapper.insert(cookbook);

    }

}
